﻿using System;
using System.Collections.Generic;
using NmbpProject2.DataLayer;
using NmbpProject2.DboClasses;

namespace NmbpProject2.BusinessLayer {

  internal class PersonBL {

    #region Private variables

    private readonly PersonDL _personDL = new PersonDL ();

    #endregion

    #region Methods

    /// <summary>
    /// Dohvaća osobe po jmbg-u.
    /// </summary>
    /// <param name="jmbg"></param>
    /// <returns></returns>
    public Person findByJmbg (long jmbg) {
      Person person = _personDL.findByJmbg (jmbg);
      return person;
    }

    /// <summary>
    /// Poziva spremanje zapisa nove osobe u bazu podataka.
    /// </summary>
    /// <param name="firstName"></param>
    /// <param name="lastName"></param>
    /// <param name="jmbg"></param>
    public void insertPerson (string firstName, string lastName, long jmbg) {
      _personDL.insertPerson (firstName, lastName, jmbg);
    }

    /// <summary>
    /// Dohvaća sve osobe.
    /// </summary>
    /// <returns></returns>
    public List<Person> getAllPeople () {
      return _personDL.getAllPeople ();
    }

    /// <summary>
    /// Poziva brisanje osobe iz baze podataka.
    /// </summary>
    /// <param name="person"></param>
    public void delete (Person person) {
      _personDL.delete (person);
    }

    /// <summary>
    /// Poziva brisanje više osoba iz baze podataka.
    /// </summary>
    /// <param name="people"></param>
    public void delete (List<Person> people) {
      foreach (Person person in people) {
        delete (person);
      }
    }

    /// <summary>
    /// Poziva ažuriranje osobe u bazi podataka.
    /// </summary>
    /// <param name="person"></param>
    /// <param name="firstName"></param>
    /// <param name="lastName"></param>
    /// <param name="jmbg"></param>
    public void update (Person person, string firstName, string lastName, long jmbg) {
      _personDL.update (person, firstName, lastName, jmbg);
    }

    #endregion

  }
}